<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100vw;
            height: 100vh;
            background-color: #111;
        }
        .container{
            position: relative;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .container .square{
            position: absolute;
            width: 200px;
            height: 200px;
        }
        /* 方格 */
        .container .square::before{
            content: "";
            position: absolute;
            width: 20px;
            height: 20px;
            background-color: #0f0;
            box-shadow: 0 0 0 8px #0f03,0 0 0 15px #0f01;
            animation: animateSquare 4s linear infinite;
        }
        .container .square span{
            position: absolute;
            /* left right bottom top 的简写 */
            inset: 10px;
            overflow: hidden;
            transform: rotate(calc(90deg*var(--i)));
        }
        /* 细线 */
        .container .square span::before{
            content: "";
            position: absolute;
            width: 100%;
            height: 4px;
            background-color: #0f0;
            transform: translate(-100%);
            animation: animate 4s linear infinite;
            animation-delay: calc(1s*var(--i));
        }
        @keyframes animate {
            0%{
                transform: translateX(-100%);
            }
            50%,100%{
                transform: translateX(100%);
            }
        }
        @keyframes animateSquare {
            0%{
                transform: translate(2px,2px);
            }
            25%{
                transform: translate(178px,2px);
            }
            50%{
                transform: translate(178px,178px);
            }
            75%{
                transform: translate(2px,178px);
            }
            100%{
                transform: translate(2px,2px);
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="square">
            <span style="--i:0;"></span>
            <span style="--i:1;"></span>
            <span style="--i:2;"></span>
            <span style="--i:3;"></span>
        </div>
    </div>
</body>
</html>